package cn.niitcxl.config;

import cn.niitcxl.interceptor.AdminInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class LoginConfig implements WebMvcConfigurer {
    //配置拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加拦截器
        InterceptorRegistration registration = registry.addInterceptor(new AdminInterceptor());
        registration.addPathPatterns("/**");//拦截所有的请求 查看是否登录
        //排除拦截的资源  静态资源 让用户进行登录
        registration.excludePathPatterns("/login.html",
                "/login",
                "/index.html",
                "/**/*.js",
                "/**/*.png",
                "/**/*.gif",
                "/**/*.css",
                "/**/*.woff",
                "/files/getFileTypePageCondition",
                "/files/deleteByPath",
                "/**/*.jpg",
                "/**/message.html",
                "/message/getPage",
                "/message/save",
                "/message"
        );

    }
}